﻿/**
 * Created in 2012-3-2.
 */
package kit4j.tests.jdk.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.junit.Test;

/**
 * 
 * @author MiniKnife
 *
 */
public class TestIterator {

	@Test
	public void testIterator() {
		Iterator<?> it = getIterator();
		
		while(it.hasNext()) {
			System.out.println(it.next());
		}
	}
	
	private Iterator<?> getIterator() {
		final List<String> list = new ArrayList<String>();
		
		list.add("1");
		list.add("2");
		list.add("3");
		list.add("4");
		list.add("5");
		list.add("6");
		
		return new Iterator<String>() {

			@Override
			public boolean hasNext() {
				return list.iterator().hasNext();
			}

			@Override
			public String next() {
				return list.iterator().next();
			}

			@Override
			public void remove() {
				list.iterator().remove();
			}
			
		};
	}

}
